From a30b79ec76eb5ea7b0184362e199be4449b20625 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Mon, 10 Sep 2012 04:57:25 +0000 Subject: [PATCH] Clean up a bunch of clang warnings while on the plane. --- gpsbabel/alan.c | 3 ++- gpsbabel/garmin_gpi.h | 2 +- gpsbabel/garmin_tables.c | 4 ++-- gpsbabel/garmin_tables.h | 2 +- gpsbabel/garmin_txt.c | 9 +++++---- gpsbabel/itracku.c | 2 +- gpsbabel/jeeps/gpsdatum.h | 8 ++++---- gpsbabel/jeeps/gpslibusb.c | 6 +++--- gpsbabel/jeeps/gpsmath.c | 2 +- gpsbabel/jeeps/gpsmath.h | 2 +- gpsbabel/jeeps/gpsusbcommon.c | 2 +- gpsbabel/jeeps/gpsutil.c | 6 +++--- gpsbabel/jeeps/gpsutil.h | 6 +++--- gpsbabel/lmx.c | 2 +- gpsbabel/mapopolis.c | 2 +- gpsbabel/mmo.c | 4 ++-- gpsbabel/naviguide.c | 12 ++++++------ gpsbabel/skytraq.c | 4 ++-- gpsbabel/xcsv_tokens.in | 2 +- 19 files changed, 41 insertions(+), 39 deletions(-) diff --git a/gpsbabel/alan.c b/gpsbabel/alan.c index 0eea38e6d..d855fd66e 100644 --- a/gpsbabel/alan.c +++ b/gpsbabel/alan.c @@ -421,7 +421,8 @@ static void trl_swap(struct trldata* trldata) /**************************************************************************/ -static void str2lab(char* dest, char* src, int len, char* fmt, int n) +static void str2lab(char* dest, const char* src, int len, const char* fmt, + int n) { int i,j; diff --git a/gpsbabel/garmin_gpi.h b/gpsbabel/garmin_gpi.h index 9e816ba11..4e2b11f0b 100644 --- a/gpsbabel/garmin_gpi.h +++ b/gpsbabel/garmin_gpi.h @@ -1,7 +1,7 @@ #ifndef GARMIN_GPI_H #define GARMIN_GPI_H -static char gpi_bitmap[] = { +static unsigned char gpi_bitmap[] = { 0x00,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x00,0x00,0x40,0x02,0x00,0x00, 0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0xff,0x00,0xff,0x00,0x01,0x00,0x00,0x00, 0x6c,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/gpsbabel/garmin_tables.c b/gpsbabel/garmin_tables.c index 161f15c56..287224cff 100644 --- a/gpsbabel/garmin_tables.c +++ b/gpsbabel/garmin_tables.c @@ -729,7 +729,7 @@ gt_switch_display_mode_value(const unsigned char display_mode, const int protoid } } -char* +const char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic) { icon_mapping_t* i; @@ -993,7 +993,7 @@ gt_get_mps_grid_longname(const grid_type grid, const char* module) const char* gt_get_mps_datum_name(const int datum_index) { - char* result; + const char* result; datum_mapping_t* d; result = GPS_Math_Get_Datum_Name(datum_index); diff --git a/gpsbabel/garmin_tables.h b/gpsbabel/garmin_tables.h index 8a010904e..b31de0fc2 100644 --- a/gpsbabel/garmin_tables.h +++ b/gpsbabel/garmin_tables.h @@ -36,7 +36,7 @@ typedef struct icon_mapping { typedef enum {MAPSOURCE, PCX, GARMIN_SERIAL, GDB} garmin_formats_e; -char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic); +const char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic); int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_format); extern icon_mapping_t garmin_icon_table[]; diff --git a/gpsbabel/garmin_txt.c b/gpsbabel/garmin_txt.c index a6e288f9b..3be03bf24 100644 --- a/gpsbabel/garmin_txt.c +++ b/gpsbabel/garmin_txt.c @@ -139,7 +139,7 @@ static info_t* route_info; static int route_idx; static info_t* cur_info; -static char* headers[] = { +static const char* headers[] = { "Name\tDescription\tType\tPosition\tAltitude\tDepth\tProximity\tTemperature\t" "Display Mode\tColor\tSymbol\tFacility\tCity\tState\tCountry\t" "Date Modified\tLink\tCategories", @@ -531,11 +531,11 @@ write_waypt(const waypoint* wpt) unsigned char wpt_class; garmin_fs_p gmsd; char* wpt_type; - char* dspl_mode; + const char* dspl_mode; const char* country; double x; int i, icon, dynamic; - char* icon_descr; + const char* icon_descr; gmsd = GMSD_FIND(wpt); @@ -602,7 +602,8 @@ write_waypt(const waypoint* wpt) icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic); print_string("%s\t", icon_descr); if (dynamic) { - xfree(icon_descr); + // sleaze alert: cast away constness. + xfree((char *) icon_descr); } print_string("%s\t", GMSD_GET(facility, "")); diff --git a/gpsbabel/itracku.c b/gpsbabel/itracku.c index be26c2e7a..8efd03c05 100644 --- a/gpsbabel/itracku.c +++ b/gpsbabel/itracku.c @@ -57,7 +57,7 @@ static void itracku_file_read_waypts(gbfile* fin, void (*waypt_add)(waypoint* wp static void itracku_file_write_waypt(gbfile* fout, const waypoint* wpt); /* itracku device access */ -static const char read_update_data_command[] = { 0x60, 0xb5, 0, 0, 0, 0, 0 }; /* command string to start memory dump */ +static const unsigned char read_update_data_command[] = { 0x60, 0xb5, 0, 0, 0, 0, 0 }; /* command string to start memory dump */ static const int timeout = 1000; /* timeout for all read operations */ static const char update_end_marker[] = "WP Update Over"; /* end marker for the memory dump */ static const int update_end_marker_size = sizeof(update_end_marker); diff --git a/gpsbabel/jeeps/gpsdatum.h b/gpsbabel/jeeps/gpsdatum.h index faa54fe86..ff7475026 100644 --- a/gpsbabel/jeeps/gpsdatum.h +++ b/gpsbabel/jeeps/gpsdatum.h @@ -9,7 +9,7 @@ extern "C" typedef struct GPS_SEllipse { - char* name; + const char* name; double a; double invf; } GPS_OEllipse, *GPS_PEllipse; @@ -48,7 +48,7 @@ extern "C" typedef struct GPS_SDatum { - char* name; + const char* name; int ellipse; double dx; double dy; @@ -187,7 +187,7 @@ extern "C" typedef struct GPS_SDatum_Alias { - char* alias; + const char* alias; const int datum; } GPS_ODatum_Alias, *GPS_PDatum_Alias; @@ -227,7 +227,7 @@ extern "C" /* UK Ordnance Survey Nation Grid Map Codes */ - static char* UKNG[]= { + static const char* UKNG[]= { "SV","SW","SX","SY","SZ","TV","TW","SQ","SR","SS","ST","SU","TQ","TR", "SL","SM","SN","SO","SP","TL","TM","SF","SG","SH","SJ","SK","TF","TG", "SA","SB","SC","SD","SE","TA","TB","NV","NW","NX","NY","NZ","OV","OW", diff --git a/gpsbabel/jeeps/gpslibusb.c b/gpsbabel/jeeps/gpslibusb.c index acb732c78..5122ff11c 100644 --- a/gpsbabel/jeeps/gpslibusb.c +++ b/gpsbabel/jeeps/gpslibusb.c @@ -26,7 +26,7 @@ #include "config.h" #endif #if HAVE_LIBUSB -#include +#include "usb.h" #include "gps.h" #include "garminusb.h" #include "gpsusbcommon.h" @@ -204,9 +204,9 @@ gusb_atexit_teardown(void) unsigned gusb_reset_toggles(void) { - static const char oinit[12] = + static const unsigned char oinit[12] = {0, 0, 0, 0, GUSB_SESSION_START, 0, 0, 0, 0, 0, 0, 0}; - static const char oid[12] = + static const unsigned char oid[12] = {20, 0, 0, 0, 0xfe, 0, 0, 0, 0, 0, 0, 0}; garmin_usb_packet iresp; int t; diff --git a/gpsbabel/jeeps/gpsmath.c b/gpsbabel/jeeps/gpsmath.c index 1a025012d..a5e9de25d 100644 --- a/gpsbabel/jeeps/gpsmath.c +++ b/gpsbabel/jeeps/gpsmath.c @@ -2572,7 +2572,7 @@ int32 GPS_Lookup_Datum_Index(const char* n) return -1; } -char* +const char* GPS_Math_Get_Datum_Name(const int datum_index) { return GPS_Datum[datum_index].name; diff --git a/gpsbabel/jeeps/gpsmath.h b/gpsbabel/jeeps/gpsmath.h index c1ac21145..839fece39 100644 --- a/gpsbabel/jeeps/gpsmath.h +++ b/gpsbabel/jeeps/gpsmath.h @@ -141,7 +141,7 @@ extern "C" const double lambda0, const double E0, const double N0); int32 GPS_Lookup_Datum_Index(const char* n); - char* GPS_Math_Get_Datum_Name(const int datum_index); + const char* GPS_Math_Get_Datum_Name(const int datum_index); #endif diff --git a/gpsbabel/jeeps/gpsusbcommon.c b/gpsbabel/jeeps/gpsusbcommon.c index fb3ae7306..79e5b2045 100644 --- a/gpsbabel/jeeps/gpsusbcommon.c +++ b/gpsbabel/jeeps/gpsusbcommon.c @@ -212,7 +212,7 @@ gusb_list_units() void gusb_id_unit(garmin_unit_info_t* gu) { - static const char oid[12] = + static const unsigned char oid[12] = {20, 0, 0, 0, 0xfe, 0, 0, 0, 0, 0, 0, 0}; garmin_usb_packet iresp; int i; diff --git a/gpsbabel/jeeps/gpsutil.c b/gpsbabel/jeeps/gpsutil.c index 8a6201b7e..a9374c68a 100644 --- a/gpsbabel/jeeps/gpsutil.c +++ b/gpsbabel/jeeps/gpsutil.c @@ -457,7 +457,7 @@ int32 GPS_Util_Block(int32 fd, int32 state) ** @@ ****************************************************************************/ -void GPS_Warning(char* s) +void GPS_Warning(const char* s) { if (!gps_warning) { return; @@ -481,7 +481,7 @@ void GPS_Warning(char* s) ** @@ ****************************************************************************/ -void GPS_Fatal(char* s) +void GPS_Fatal(const char* s) { fprintf(stderr,"[FATAL] %s\n",s); @@ -501,7 +501,7 @@ void GPS_Fatal(char* s) ** @@ ****************************************************************************/ -void GPS_Error(char* fmt, ...) +void GPS_Error(const char* fmt, ...) { va_list argp; va_start(argp, fmt); diff --git a/gpsbabel/jeeps/gpsutil.h b/gpsbabel/jeeps/gpsutil.h index 625176659..3b8f25dac 100644 --- a/gpsbabel/jeeps/gpsutil.h +++ b/gpsbabel/jeeps/gpsutil.h @@ -24,10 +24,10 @@ extern "C" void GPS_Util_Put_Uint(UC* s, const uint32 v); uint32 GPS_Util_Get_Uint(const UC* s); - void GPS_Warning(char* s); - void GPS_Error(char* fmt, ...); + void GPS_Warning(const char* s); + void GPS_Error(const char* fmt, ...); void GPS_Serial_Error(const char* hdr, ...); - void GPS_Fatal(char* s); + void GPS_Fatal(const char* s); void GPS_Enable_Error(void); void GPS_Enable_Warning(void); void GPS_Disable_Error(void); diff --git a/gpsbabel/lmx.c b/gpsbabel/lmx.c index 53d43eef7..66c71deb0 100644 --- a/gpsbabel/lmx.c +++ b/gpsbabel/lmx.c @@ -63,7 +63,7 @@ lmx_wr_deinit(void) gbfclose(ofd); } -static char* +static const char* lmx_stag(int tag) { switch (tag) { diff --git a/gpsbabel/mapopolis.c b/gpsbabel/mapopolis.c index 4ff7c7d27..7846a347e 100644 --- a/gpsbabel/mapopolis.c +++ b/gpsbabel/mapopolis.c @@ -93,7 +93,7 @@ wr_deinit(void) mkshort_del_handle(&mkshort_handle); } -convert_rec0(struct record0* rec0) +void convert_rec0(struct record0* rec0) { Lon1 = be_read32(&rec0->lon1) / LONDIV; Lat1 = be_read32(&rec0->lat1) / LATDIV; diff --git a/gpsbabel/mmo.c b/gpsbabel/mmo.c index 979e3c24c..bbe234944 100644 --- a/gpsbabel/mmo.c +++ b/gpsbabel/mmo.c @@ -186,7 +186,7 @@ mmo_readstr(void) len = (unsigned)gbfgetc(fin); if (len > 0) { int ii, jj, ch, resbytes=0; - res = xmalloc(len*2 + 1); // bigger to allow for utf-8 expansion + res = (char *) xmalloc(len*2 + 1); // bigger to allow for utf-8 expansion for (ii=0; ii